package com.yy.tools;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.kit.PropKit;

public class OpenId {
	public static String getOpenId(String code){
		

		System.out.println(code);
		String s=HttpRequest.sendGet("https://api.weixin.qq.com/sns/oauth2/access_token", "appid="+PropKit.get("appId")+"&secret="+PropKit.get("appSecret")+"&code="+code+"&grant_type=authorization_code");
        System.out.println(s);
        
        JSONObject jo = JSONObject.parseObject(s);
        
        String openid = jo.get("openid")+"";
        
		return openid;
	}
	
	public static String getHengId(String openid){

        System.out.println(openid);
        String isCz=HttpRequest.sendGet("http://yiyikefu.com/engineer/returnOpenid", "openid="+openid+"&api_id=wx833&api_sign=wx885b3e4e8c7b4d89e01e");
        
        System.out.println(isCz);
        
        JSONArray ja = JSONArray.parseArray(isCz);
        JSONObject jo1 = ja.getJSONObject(0);
        String heng_id = jo1.get("heng_id")+"";
        System.out.println(heng_id);
		return heng_id;
	}
}
